<div class="main-content">
    <div class="section__content section__content--p20">
        <div class="container-fluid">
            <div class="row m-b-30">
                <div class="col-lg-12">
                    <div class="overview-wrap">
                        <h2 class="title-1">留言编辑</h2>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-lg-12">
                    <div class="card">
                        <div class="card-header">
                            <strong>留言编辑</strong>
                        </div>
                        <div class="card-body">
                            <form name="form_edit" id="form_edit" action="index.php?r=admin/message/edit" method="post">
                                <input type="hidden" name="message_id" value="<?php echo $id; ?>"/>
                                <input type="hidden" name="YII_CSRF_TOKEN"
                                       value="<?php echo Yii::app()->request->csrfToken; ?>"/>
                                <div class="form-group">
                                    <label class=" form-control-label">作者</label>
                                    <div class="form-control">
                                        <?php echo $message['username']; ?>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label class=" form-control-label">标题</label>
                                    <div class="form-control">
                                        <?php echo $message['title']; ?>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label class=" form-control-label">内容</label>
                                    <textarea name="content" style="width:100%;height:250px;">
                            <?php echo $message['content']; ?>
                        </textarea>
                                </div>

                                <div class="form-group">
                                    <label class=" form-control-label">回复</label>
                                    <textarea name="reply" style="width:100%;height:250px;">
                            <?php echo $message['reply']; ?>
                        </textarea>
                                </div>


                                <div class="form-group">
                                    <button type="submit" name="submit" id="submit"
                                            class="btn btn-primary btn-lg btn-block">保存
                                    </button>
                                </div>

                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="<?php echo Yii::app()->request->baseUrl ?>/static/admin/lib/kindeditor/kindeditor-min.js"></script>
<script charset="utf-8"
        src="<?php echo Yii::app()->request->baseUrl ?>/static/admin/lib/kindeditor/lang/zh_CN.js"></script>
<script>
    var editor;
    var editor2;
    $(function () {
        editor = initEdit("content", 'message')
        editor2 = initEdit("reply", 'message')
    });

    function save() {
        if ($("#form_edit").validationEngine('validate')) {
            editor.sync();
            editor2.sync();
            var replay = editor2.html();
            if (replay.length > 0) {
                document.forms['form_edit'].submit();
            } else {
                alert('回复不能为空');
            }
        }
    }
</script>